<?php 
require_once("includes/config.php"); 

  
    $length = 20;
    
    if( isset($_GET['page'])  && !empty($_GET['page'] ))
    {
      $page =  filter_var($_GET['page'], FILTER_SANITIZE_NUMBER_INT);
      $start = $page*20 - 20;
    }
    else
    {
      $start = 0;
      $page = 1;
    }

    $payments= query("SELECT * FROM service_vouchers WHERE owner_id= ? LIMIT ?,? ",$_SESSION['user_id'] ,$start,$length);
    $sqlCount = query("SELECT COUNT(*) FROM service_vouchers WHERE owner_id = ?",$_SESSION['user_id']);
    
    $totalPages = $sqlCount[0]['COUNT(*)'];
   
    render("service_vouchers.php", array("title"=>"ادارة سنادات الخدمات","page"=>$page,"totalPages"=>$totalPages,"payments"=>$payments,"start"=>$start,"length"=>$length));
  
?>